package cn.geminis.warehouse.service.delivery.entity;

import cn.geminis.lowcode.annotation.*;
import cn.geminis.warehouse.service.basic.entity.ProductBatch;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.ManyToOne;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;


/**
 * 出库单明细
 */
@Getter
@Setter
@UuidEntity
@QueryFilter
@CrudRepository
@CrudController
public class DeliveryDetail {

    /**
     * 入库单
     */
    @ManyToOne(cascade = {CascadeType.ALL}, optional = false)
    @JsonIgnoreProperties
    @QueryFilterProperty(fieldName = "delivery.id", propertyName = "deliveryId", propertyType = "String")
    private Delivery delivery;

    /**
     * 商品批次
     */
    @ManyToOne(optional = false)
    @QueryFilterProperty(fieldName = "productBatch.id", propertyName = "productBatchId", propertyType = "String")
    @QueryFilterProperty(fieldName = "productBatch.product.id", propertyName = "productBatchProductId", propertyType = "String")
    @QueryFilterProperty(fieldName = "productBatch.product.no", propertyName = "productBatchProductNo", propertyType = "String")
    private ProductBatch productBatch;

    /**
     * 商品价格
     */
    @Column(nullable = false)
    private BigDecimal priceLoad;

    /**
     * 商品数量
     */
    @Column(nullable = false)
    private int amount;

}
